using UnityEngine;
using System.Collections.Generic;
using TowerDefence_Zombie;

namespace GameHelper.Config
{
    public static class GameConfig
    {
        private static Dictionary<string, ConfigBase> _configDic = new();

        public static T GetConfig<T>() where T : ConfigBase
        {
            T config = null;
            string configName = typeof(T).Name;

            if (!_configDic.TryGetValue(configName, out var targetConfig))
            {
                config = Resources.Load<T>("Configs/" + configName);
                _configDic[configName] = config;
                config.Load();
                return config;
            }
            return (T)targetConfig;
        }
    }
}
